    <!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>塞纳皇宫-网站后台管理系统</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/static/admin/img/logo.png" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico"> <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="/static/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <style>        #div1{
        width:62px;
        height: 32px;
        border-radius: 50px;
        position: relative;
    }
    #div2{
        width: 26px;
        height: 26px;
        border-radius: 48px;
        position: absolute;
        background: white;
        /*box-shadow: 0px 2px 4px rgba(0,0,0,0.4);*/
    }
    .open1{
        background: #24b7e5;
    }
    .open2{
        top: 3px;
        right: 3px;
    }
    .close1{
        background: #cdcdcd;
        border-left: transparent;
    }
    .close2{
        left: 4px;
        top: 3px;
    }
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>栏目广告 </h5>
                       <div class="ibox-tools">
                            <!--<a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            &lt;!&ndash;<ul class="dropdown-menu dropdown-user">
                                <li><a href="table_data_tables.html#">选项1</a>
                                </li>
                                <li><a href="table_data_tables.html#">选项2</a>
                                </li>
                            </ul>&ndash;&gt;
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>-->
                        </div>
                    </div>
                    <div class="ibox-content">
                      <div class="">
                            <a onclick="fnClickAddRow();" href="javascript:void(0);" class="btn btn-primary ">添加广告</a>
                            <a onclick="fnClickAddClass();" href="javascript:void(0);" class="btn  " style="margin-left:10px;border: 1px #333 solid;color:#000;">编辑分类</a>
                        </div>
                        <div class="row" style="position:absolute;left: 198px;z-index: 3;width: 1200px;margin-bottom:10px; height: 33px; ">
                            <form action="/admin.php/banner/index" method="post">
                                <div  style="width: 160px;display: inline-block; margin-left: 10px; ">
                                    <select type="search" class="form-control select—sou" name="is_show" style="height: 33px;margin-bottom:10px;">
                                        <option  value="">按推荐状态</option>
                                        <option {if isset($_POST['is_show']) && $_POST['is_show']=="0"} selected="selected"{/if} value="0">未推荐</option>
                                        <option  {if isset($_POST['is_show']) && $_POST['is_show']=="1"} selected="selected"{/if} value="1">已推荐</option>
                                    </select>
                                </div>
                                <div  style="width: 160px;display: inline-block;margin-left: 10px;">
                                    <select type="search" class="form-control select—sou" name="class_id" style="height: 33px;margin-bottom:10px;">
                                        <option  value="">按列表分类</option>
                                        {volist name="data.info" id="v"}
                                        <option value="{$v.class_id}">{$v.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="sousuo" style="display: inline-block;margin-left: 10px;">
                                    <button type="submit" class="btn btn-primary " >搜索</button>
                                </div>
                            </form>
                        </div>

                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th>排序</th>
                                    <th>标题</th>
                                    <th>主图(PC)</th>
                                  <!--  <th>主图(Mobile)</th>-->
                                    <th>栏目</th>
                                    <th>状态</th>
                                    <th>添加时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            {volist name="data.list" id="v"}
                                <tr class="gradeX">
                                    <td ><input style="width: 40px;-webkit-appearance: none;" type="text" onblur="changeSort({$v.id})" name="sort_{$v.id}" value="{$v.sort}"></td>
                                    <td>{$v.title}</td>
                                    <td><img width="100" height="40px;" src="{$v.banner_img}"></td>
                                  <!--  <td>{if isset($v.banner_img_mobile) && $v.banner_img_mobile !==''}<img width="60" height="40px;" src="{$v.banner_img_mobile}">{/if}</td>-->

                                    <td class="center">{volist name="data.info" id="c"}{if $v.class_id==$c.class_id}{$c.name}{/if}{/volist}</td>

                                    <!--<td class="center">{if $v.is_show==1}显示{else}不显示{/if}</td>-->
                                    <td>
                                        <input style="width: 40px;-webkit-appearance: none;" type="hidden" name="is_show" value="{$v.is_show}">
                                        {if $v.is_show==1}
                                        <label class="open1" onclick="tastra({$v.id})" id="div1">
                                            <label  class="open2"   id="div2"></label>
                                        </label>
                                        {else}
                                        <label class="close1" onclick="tastra({$v.id})" id="div1">
                                            <label class="close2"   id="div2"></label>
                                        </label>
                                        {/if}
                                    </td>
                                    <td class="center">{if $v.create_time >0}{$v.add_time|date='Y-m-d',###}{/if}</td>

                                    <td class="center"><a href="javascript:;" onclick="edit({$v.id})">编辑</a>&nbsp;&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="del(this,{$v.id})">删除</a></td>
                                </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <!--<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>-->
    <!--<script src="/static/admin/js/plugins/jeditable/jquery.jeditable.js"></script>-->
    <!-- Data Tables -->
    <script src="/static/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="/static/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>
    <!-- 自定义js -->
    <script src="/static/admin/js/content.js?v=1.0.0"></script>
    <script src="/static/admin/layer/layer.js"></script>
    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function () {
            $('.dataTables-example').dataTable();


        });
        function fnClickAddRow() {
            window.location.href="/admin.php/banner/add_banner";

        }
        function fnClickAddClass() {
            window.location.href="/admin.php/banner/vclass";

        }

        //推荐状态
        function tastra(id) {
            var div2=document.getElementById("div2");
            var div1=document.getElementById("div1");
            $.post("/admin.php/banner/start",{id:id},function(e){
                if(1 == e.code){
                    layer.msg(e.msg);
                    div1.className=(div1.className=="close1")?"open1":"close1";
                    div2.className=(div2.className=="close2")?"open2":"close2";
                    window.location.reload();
                }else{
                    alyer.msg(e.msg);
                    return false;
                }
            })
        }
        //编辑
        function edit(id){
            window.location.href="/admin.php/banner/add_banner?id="+id;
        }
        //删除
        function del(obj,id){
            layer.confirm('确认要删除吗？',function(){
                $.post("/admin.php/banner/bannerdel",{id:id},function(e){
                    if(1==e.code){
                        layer.msg(e.msg);
                        $(obj).parents("tr").remove();
                    }else{
                        layer.msg(e.msg);
                    }
                 },'json')
            });
        }
        //排序
        function changeSort(id){
            var sort_name = 'sort_'+id+'';
            var new_sort = $("input[name='"+sort_name+"']").val();
            if(isNaN(new_sort)){
                layer.msg('必须是数字');
                return false;
            }
            $.post("/admin.php/banner/ChangeSort",{sort:new_sort,id:id},function(e){
                if(1 == e.code){
                    layer.msg(e.msg);
                    window.location.reload();
                }else{
                    alyer.msg(e.msg);
                    return false;
                }
            })
        }
    </script>

    
    

</body>

</html>
